<!DOCTYPE html>
<html>
<head lang="zh">
    <meta charset="UTF-8">
    <title>商品详情</title>
    <link rel="stylesheet" href="./css/bootstrap.min.css"/>
    <link rel="stylesheet" href="./css/cart/shoppingcart.css"/>
</head>
<body onunload="checkLeave()">


<div class="start-border"></div>
<div class="container" style="overflow: hidden;">
    <!--标题-->
    <div class="url-a">
        <p><a href="#">首页</a><span> / 购物车</span></p>
    </div>

    <!--导航栏-->
    <div class="thead-style">
            <span class="col-lg-2 left-p0" >
                <input type="checkbox" id="chkAll" name="chkAll" onclick="chkAll_onclick(this)" style="margin-right: 15px"/>
                全选
            </span>
        <span class="col-lg-3 left-p0">商品信息</span>
        <span class="col-lg-2 left-p0">单价</span>
        <span class="col-lg-2 left-p0">数量</span>
        <span class="col-lg-2 left-p0">金额</span>
        <span class="col-lg-1 left-p0">操作</span>
    </div>


    <ul class="list-ul">
        <!--购物车1-->
        <li>
            <div class="cart-title">
                    <span>
                        <input type="checkbox" name="chkSort" value="chkFruit1" onclick="chkSort_onclick(this)" style="margin-right: 30px"/>
                        今日份特价
                        <img src="./img/cart/activity1.png"/>
                    </span>
                    <span class="link1">
                        <a class="show-hide">
                            <img src="./img/cart/open.png" alt=""/>
                            <span>每日优惠</span>
                        </a>
                    </span>
            </div>


            <ul class="cart-inner fruit-activity-list">

            </ul>

        </li>


        <!--购物车2-->
        <li>
            <div style="height: 50px;line-height: 50px;border-bottom: 1px solid #ddd;margin-top: 35px;padding-bottom: 17px">
                <span><input type="checkbox" name="chkSort" value="chkFruit2" onclick="chkSort_onclick(this)" style="margin-right: 32px"/>新鲜水果</span>
                <span style="float: right;padding-right: 10px;color: #999;">
                        <a class="show-hide">
                            <img src="./img/cart/open.png" alt="" style="padding-right: 6px"/>
                            <span style="padding-top: 3px">新鲜水果</span>
                        </a>
                    </span>
            </div>

            <ul class="cart-inner fruit-list">

            </ul>
        </li>

    </ul>

    <!--结算-->
    <div class="pay-outter">
            <span class="col-lg-8 text1">
                <input type="checkbox" name="chkAll" onclick="chkAll_onclick(this)" style="margin-right: 15px"/>
                全选&nbsp;&nbsp;&nbsp;&nbsp;
                <span style="font-size: 17px">已选<span class="total-account" style="color: #a9010d;">0</span>件</span>
            </span>
        <span class="col-lg-2 text1">合计：￥<span class="total-price" style="color: #a9010d;">0.00</span></span>
        <span class="col-lg-2 text-button1">
                <button class="btn" id="pay" onclick="fruit_pay()">去结算</button>
            </span>
    </div>

    <!-- 删除确认Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel"><strong>购物车删除</strong></h4>
                </div>
                <div class="modal-body">
                    是否确认删除该水果？
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" onclick="deletefruit()" >确认</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/cart/cart-select.js"></script>
<script src="./js/cart/cart.js"></script>

<script>
    $('#pay').attr("disabled","disabled");

    $('input[name="chkAll"],input[name="chkSort"],ul.fruit-list,ul.fruit-activity-list').click(function () {

        var selected_amount = parseInt($('span.total-account').text());

        if (selected_amount == 0){
            $('#pay').attr("disabled","disabled");
            $('#pay').css("background-color","#e7e7e7");
        }else{
            $('#pay').removeAttr("disabled");
        }

    })

    $('#pay').hover(function () {

        var selected_amount = parseInt($('span.total-account').text());

        if (selected_amount != 0){
            $('#pay').css("background-color","#b7d37f")
        }
    })

//    $('#pay').click(function (){
//        var cartFruits = get_cart();
//
//        $.post({
//            url: "/shoppingcart/savecart",
//            contentType: "application/json",
//            data:JSON.stringify(cartFruits)
//        })
//
//        //获取选中的水果
//        cartFruits = get_cart();
//        var payFruits = new Array();
//        var fruitNames = $('input.carter:checked');
//
//        for ( var i=0; i<fruitNames.length; i++){
//            var fruitName = fruitNames[i].parentElement.parentElement.children[2].children[1].children[1].innerHTML;
//
//            for (var j=0; j<cartFruits.length; j++){
//                if(fruitName == cartFruits[j].fruitName){
//                    payFruits.push(cartFruits[j]);
//                    break;
//                }
//            }
//        }
//
//    })
</script>
</body>
</html>